package com.example.mvvmdatabinding.databinding;

import android.os.Bundle;
import android.view.View;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
import androidx.databinding.DataBindingUtil;
import com.example.mvvmdatabinding.R;
import com.example.mvvmdatabinding.bean.Account;


public class DatabingingActivity extends AppCompatActivity {

    private Account account;


    private ActivityDemoBinding binding;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        binding = DataBindingUtil.setContentView(this, R.layout.activity_demo);
        //ActivityMainBinding和activity_main.xml的布局生成
        account = new Account();
        account.setName("TEST");
        account.setLevel(100);
        binding.setAccount(account);
        binding.setActivity(this);
    }

    public void onclick(View view){
        //Toast.makeText(this,"点击了",Toast.LENGTH_SHORT).show();
        int level = account.getLevel();
        account.setLevel(level+1);
       // binding.setAccount(account);
    }
}